package com.code;

/**
 * 返回数组下标  数组里2数和为 target
 * Created by lucky on 2018/9/19.
 */
public class Code1 {

    public static void main(String[] args) {
        int[] nums = {3,3,4,7,12} ;
        int target = 19;
        int[] ints = twoSum(nums, target);
        for (int i= 0 ; i < ints.length ; i++){
            System.out.println(ints[i]);
        }

    }

    public static int[] twoSum(int[] nums, int target) {
        int[] m = null;
        for (int i = 0 ; i < nums.length ; i++){
            for (int j = 1 ; j < nums.length ; j ++){
                if(nums[i] + nums[j] == target && i != j){
                    m = new int[]{i, j};
                }
            }
        }
        return m;
    }
}
